﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SMTC.BO.UserPower;
using SMTC.WebCommon.Common;

public partial class UserPower_MounterMaintenance : BasePage
{
   private MounterMaintenance maintenance = new MounterMaintenance();
   private DeleteMounterMaintenance deleteinfo = new DeleteMounterMaintenance();
   private SearchTypeMounterMaintenance type = new SearchTypeMounterMaintenance();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
           
            GridviewMounterMaintenanceBind();
        }
    }
    protected void GridviewMounterMaintenanceBind()
    {
        GridviewMounterMaintenance.DataSource = maintenance.Mounter_Maintenance().Tables[0].DefaultView;
        GridviewMounterMaintenance.DataBind();
    
    }
    protected void GridviewMounterMaintenance_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        if (e.NewPageIndex >= 0 && e.NewPageIndex < GridviewMounterMaintenance.PageCount)
         GridviewMounterMaintenance.PageIndex = e.NewPageIndex;
        GridviewMounterMaintenanceBind();
    }
    protected void GridviewMounterMaintenance_RowDataBound(object sender, GridViewRowEventArgs e)
    {

        if (e.Row.RowType == DataControlRowType.DataRow)
        {

            e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#c2f6f4'");

            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
        }
  
    }
    protected void GridviewMounterMaintenance_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        deleteinfo.Delete_Mounter_Maintenance(GridviewMounterMaintenance.DataKeys[e.RowIndex].Value.ToString());
        GridviewMounterMaintenanceBind();
    }
    protected void RAbility_CheckedChanged(object sender, EventArgs e)
    {
        if (RAbility.Checked == true)
        {

            RType.Checked = false;
            RParameter.Checked = false;
            RPeople.Checked = false;
            RTime.Checked = false;
        }
    }
    protected void RType_CheckedChanged(object sender, EventArgs e)
    {
        if (RType.Checked == true)
        {
            RAbility.Checked = false;  
            RParameter.Checked = false;
            RPeople.Checked = false;
            RTime.Checked = false;
        }
    }
    protected void RParameter_CheckedChanged(object sender, EventArgs e)
    {
        if (RParameter.Checked== true)
        {
            RType.Checked = false;
            RAbility.Checked = false;
            RPeople.Checked = false;
            RTime.Checked = false;
        }
    }
    protected void RPeople_CheckedChanged(object sender, EventArgs e)
    {
        if (RPeople.Checked  == true)
        {
            RType.Checked = false;
            RAbility.Checked = false;
            RParameter.Checked= false;
            RTime.Checked = false;
        }
    }
    protected void RTime_CheckedChanged(object sender, EventArgs e)
    {
        if (RTime.Checked  == true)
        {
            RType.Checked = false;
            RAbility.Checked = false;
            RParameter.Checked = false;
            RPeople.Checked = false;

        }
    }
    protected void ButtonSearch_Click(object sender, EventArgs e)
    {
        //if (RType.Checked == true)
        //    search("MounterType", TextBoxMachineType.Text.ToString().Trim());
        //if(RAbility.Checked==true)
        //    search("MounterAbility", TextBoxAbility.Text.ToString().Trim());
        //if(RParameter.Checked==true)
        //    search("MounterParameter", TextBoxParameter.Text.ToString().Trim());
        //if(RPeople.Checked==true)
        //    search("MounterMaintenancer", TextBoxMaintenancer.Text.ToString().Trim());
        //if(RTime.Checked==true)
        //    search("MounterMaintenanceTime", TextBoxMaintenanceTime.Text.ToString().Trim());
        //GridviewMounterMaintenance.DataSource = null;
        //GridviewMounterMaintenance.DataSource = type.Search_Type_Mounter_Maintenance(TextBoxMachineType.Text.ToString().Trim()).Tables[0].DefaultView;
        //GridviewMounterMaintenance.DataBind();
        if (RType.Checked == true)
        {
            GridviewMounterMaintenance.DataSource = null;
            GridviewMounterMaintenance.DataSource = type.Search_Type_Mounter_Maintenance(TextBoxMachineType.Text.ToString().Trim().ToUpper()).Tables[0].DefaultView;
            GridviewMounterMaintenance.DataBind();
        
        }

    }
    //protected void search(string which,string value)
    //{

    //    GridviewMounterMaintenance.DataSource = null;
    //    GridviewMounterMaintenance.DataSource = type.Search_Type_Mounter_Maintenance(which ,value ).Tables[0].DefaultView;
    //    GridviewMounterMaintenance.DataBind();
    
    //}


    protected void ButtonALL_Click(object sender, EventArgs e)
    {
        GridviewMounterMaintenance.DataSource = null;
        GridviewMounterMaintenanceBind();
    }
}